package com.ztgf.commodity.api.client;

import com.ztgf.commodity.models.service.ICommodityFilterAttributesService;
import com.ztgf.commodity.models.vo.CommodityFilterOneVO;
import com.ztgf.common.constant.Result;
import com.ztgf.common.enums.CodeEnum;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/*
 * @author: chenyu.wang
 * @date: 2020-09-08
 * @description:
 */
@RestController
@RequestMapping("/api/commodityFilterAttributes")
@Api(value = "CommodityFilterAttributesApiController", tags = "筛选属性管理API接口")
public class CommodityFilterAttributesApiController {

    @DubboReference
    private ICommodityFilterAttributesService commodityFilterAttributesService;

    @PostMapping(value = "/getByParentId")
    @ApiOperation(value = "根据父级id查询筛选属性子集", notes = "根据父级id查询筛选属性子集")
    public Result updateById(Long parentId) {
        if (null != parentId) {
            List<CommodityFilterOneVO> list = commodityFilterAttributesService.getByParentId(parentId);
            return new Result<>(list);
        } else {
            return new Result<>(CodeEnum.FAIL_100002);
        }
    }

}
